package listener;

import lombok.extern.slf4j.Slf4j;

import javax.swing.*;
import java.awt.event.WindowEvent;
import java.awt.event.WindowFocusListener;

/**
 * @author zhangpeiwen
 * @since 2020/10/1
 */
@Slf4j
public class FocusLostAutoHideListener implements WindowFocusListener {
    @Override
    public void windowGainedFocus(WindowEvent e) {
        log.info("focus gained");

    }

    @Override
    public void windowLostFocus(WindowEvent e) {
        JFrame window = (JFrame)e.getSource();
        window.setVisible(false);
        log.info("focus lost");

    }
}
